<?php
    // file: process.php
    session_start();
    $_SESSION['percent'] = 0;
    $total_loops = 40;

    for ($i = 0; $i <= $total_loops; $i++) {
        $percent = ($i / $total_loops) * 100;
        usleep(50000); // pretend to be working on something
        session_start();
        $_SESSION['percent'] = number_format($percent, 0, '', ''); // update session var
        session_commit();
    }
?>